package com.central.operate.dto;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

@Data
public class ChartParams {

    /**起始时间*/
    private String startTime;

    /**查询天数:以startTime往前推*/
    private String consecutiveDay;

    /**数据统计间隔时间*/
    private String intervalHour;

    @Override
    public String toString() {
        return "ChartParams{" + "startTime='" + startTime + '\'' + ", consecutiveDay='" + consecutiveDay + '\'' + ", intervalHour='" + intervalHour + '\'' + '}';
    }

    public ChartParams(Map<String, Object> params) {
        this.startTime = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
        this.consecutiveDay = "7";
        this.intervalHour = "3";
        params.forEach((k,v) -> {
            if (v == "" || v == null){
                return;
            }
            if (k.indexOf("start_time")!= -1){
                this.startTime = v.toString();
            }
            if (k.indexOf("consecutive_day")!= -1){
                this.consecutiveDay = v.toString();
            }
            if (k.indexOf("interval_hour")!= -1){
                this.intervalHour = v.toString();
            }
        });

    }
}
